use crate::entities;
use actix_web::{get, web, Responder};
use sea_orm::DatabaseConnection;
use sea_orm::EntityTrait;
use serde_json::json;

#[get("/helloworld")]
pub async fn hello_world(db: web::Data<DatabaseConnection>) -> impl Responder {
    let users = entities::user::Entity::find()
        .all(db.get_ref())
        .await
        .unwrap();

    web::Json(json!({ "users": users }))
}